import { CategoryModel } from '~/server/models/category.model';

// 获取分类列表
export default defineEventHandler(async (): Promise<any> => {
	try {
		const categories = await CategoryModel.find({}, { __v: 0 }).sort({ createdAt: -1 });
		return {
			code: 1,
			message: '获取成功',
			data: { list: categories },
		};
	} catch (error: any) {
		return { code: 0, message: error.message };
	}
});
